package com.tanhua.server.controller;


import com.tanhua.server.service.BaiduService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 搜附近-上报地理位置
 */
@RestController
@RequestMapping("/baidu")
@Slf4j
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    /**
     * 上报地理位置 经度范围是0-180°,纬度范围是0-90°  113.870096,22.581672
     * latitude:纬度  22.581672
     * longitude:经度  113.870096
     * addrStr:位置描述
     */
    @PostMapping("/location")
    public ResponseEntity addLocation(@RequestBody Map<String, Object> paramMap){
        Double latitude = (Double) paramMap.get("latitude");//纬度
        Double longitude = (Double) paramMap.get("longitude");//经度
        String addrStr = (String)paramMap.get("addrStr");
        baiduService.addLocation(latitude,longitude,addrStr);
        return ResponseEntity.ok(null);
    }
}
